function [Jx_f, Jy_f]= Slope2(Jx, Jy,J_sign,XL,YL,current)
    N=4+randi(5);
    x=zeros(1,N);
    y=zeros(1,N);

    x(1)=1;
    y(1)=500+randi(100);
    w=5+randi(10);
    x(2)=150;
    y(2)=y(1);



    for i=3:N-1 
        x(i)=x(i-1)+10+randi(round((XL-100-x(i-1))*(i)/N));
        y(i)=100+randi(round((YL-100-y(i-1))));
    end
    
    
    x(N)=XL;
    y(N)=y(N-1);
    xg=1:XL;
    yg=(interpn(x,y,xg));
    
    for i=25:length(xg)-25
        ms=abs((yg(i-1)-yg(i))/(xg(i-1)-xg(i)));
        if yg(i-1)<yg(i)
            Jx(round(yg(i-1))-w:round(yg(i))+w,xg(i-1)-w:xg(i)+w)=J_sign*sqrt(1/(1+ms^2))*current;
            Jy(round(yg(i-1))-w:round(yg(i))+w,xg(i-1)-w:xg(i)+w)=J_sign*sqrt(1/(1+1/ms^2))*current;
        else
            Jx(round(yg(i))-w:round(yg(i-1))+w,xg(i-1)-w:xg(i)+w)=J_sign*sqrt(1/(1+ms^2))*current;
            Jy(round(yg(i))-w:round(yg(i-1))+w,xg(i-1)-w:xg(i)+w)=J_sign*sqrt(1/(1+1/ms^2))*-current;
        end
    end
        
        
    Jx(y(N)-w:y(N)+w,x(N-1):x(N))=J_sign*current;



    Jx_f=imgaussfilt(Jx,.8);
    Jy_f=imgaussfilt(Jy,.8);
end